import java.util.*;
//实现简易发牌系统
public class Text {
    public static void main(String[] args) {
        CardHolder cardHolder = new CardHolder();//创建卡包
        Person person = new Person("person1");
        Person person1 = new Person("person2");
        Person person2 = new Person("person3");

        Person[] people = new Person[]{person,person1,person2};

        for (int i = cardHolder.cards.size() - 1; i > 0 ; i--) {
            Random random = new Random();
            int num = random.nextInt(0,i);
            Card card = cardHolder.cards.get(num);
            Card cur = cardHolder.cards.get(i);
            cardHolder.cards.set(i,card);
            cardHolder.cards.set(num,cur);
        }

        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                Card card = cardHolder.cards.get(0);//拿出牌顶的牌
                cardHolder.cards.remove(0);//删除牌顶的牌
                people[j].personCards.add(card);//发到一个人的手中
            }
        }

        for (int i = 0; i < 3; i++) {
            System.out.print(people[i].getName() + ":");
            people[i].toString();
            System.out.println();
        }

        System.out.println("=========== 剩下的牌 ===========");
        int x = 0;
        for (Card card: cardHolder.cards) {
            if(x % 5 == 0){
                System.out.println();
            }
            System.out.print(card + " ");
            x++;
        }
    }
}
